import java.util.Arrays;

public class MyStack {
    public int[] elem;
    public int usedSize;

    public MyStack() {
        elem=new int[10];
    }
    public void push(int val){
        if(isFull()){
            elem= Arrays.copyOf(elem,elem.length*2);
        }
        elem[usedSize]=val;
        usedSize++;
    }
    private boolean isFull(){
        return elem.length==usedSize;
    }
    public int pop(){
        if(isEmpty()){
            return -1;
        }
        int getVal=elem[usedSize-1];
        usedSize--;
        return getVal;
    }
    public boolean isEmpty(){
        return usedSize==0;
    }
    public int peek(){
        if(isEmpty()){
            return -1;
        }
        return elem[usedSize-1];
    }
}
